/* ---------------------------------Noble Steed Engine------------------------*
Authors : Daniel Randle, Alex Bourne
Date Created :Mar 7 2013

File:
	nstexture.h

Description:
	This file contains the declaration for the NSTexture class along with any
	helper functions associated with the class
*-----------------------------------------------------------------------------*/

#ifndef NSTEXTURE_H
#define NSTEXTURE_H
#define BASE_TEX_UNIT GL_TEXTURE0
#define BASE_CUBEMAP_FACE GL_TEXTURE_CUBE_MAP_POSITIVE_X
#define NUM_TEX_TYPES 4

// Inlcudes

// Class Forward Declarations


/*----------------------------Class NSTexture----------------------------------*
Description:
	This class encapsulates loading a texture from file in to opengl and getting
	it ready for the shaders to use.
*-----------------------------------------------------------------------------*/

#include <myGL\glew.h>
#include <map>
#include <string>
#include <vector>

class NSTexture
{
public:
	enum MapType { Diffuse=0, 
		Specular, 
		Ambient, 
		Emissive, 
		Height, 
		Normal,  
		Shininess, 
		Opacity, 
		Displacement, 
		Lightmap, 
		Reflection, 
		Shadow,
		GWorldPos,
		GDiffuse,
		GNormal,
		SkyBox, 
		NumMapTypes };

	enum CubemapFace { 
		xPlus, xMinus, 
		yPlus, yMinus, 
		zPlus, zMinus, NumCubemapFaces };

	enum TexType { Tex1D = GL_TEXTURE_1D, 
		Tex2D = GL_TEXTURE_2D, 
		Tex3D = GL_TEXTURE_3D,
		CubeMap = GL_TEXTURE_CUBE_MAP };

	NSTexture(MapType mapT);
	~NSTexture();

	void disable(TexType type = Tex2D);

	std::string getFilename(TexType type = Tex2D) const;
	std::string getCubemapFilename(CubemapFace face) const;

	bool loadFromFile(const std::string & fileName, 
		const std::string & textureDir, 
		bool mipmap, 
		TexType type = Tex2D);

	bool loadCubemapFromFile(const std::string & _xPlus, 
		const std::string & _xMinus, 
		const std::string & _yPlus,
		const std::string & _yMinus,
		const std::string & _zPlus,
		const std::string & _zMinus,
		const std::string & textureDir,
		bool mipmap);

	bool loadCubemapFromFile(const std::string & cubeMapFile,
		const std::string & textureDir,
		bool mipmap);

	void use(TexType type = Tex2D);

private:

	struct TextureTarget
	{
		TextureTarget();

		GLuint texID;
		std::vector<std::string> fnames;
		bool mipMapped;
	};

	MapType mapType;
	std::string textureDirectory;
	std::map<TexType, TextureTarget> texIDMap;

	const unsigned int NumTexTypes;
};


#endif